function msgsxFn(){
    zeai.listEach(zeai.tag(main,'dt'),function(dt){
		var uid=dt.getAttribute("uid");
        dt.onclick=function(){zeai.openurl(HOST+'/m/u'+zeai.ajxext+'uid='+uid);}
        var dd=dt.nextElementSibling;
		var dl=dt.parentNode,del=zeai.tag(dl,'strong')[0];
        dd.onclick=function(){
			var newi=dl.getElementsByClassName("new")[0];
			if(!zeai.empty(newi))newi.remove();
			sessionStorage.uid=uid;
			zeai.openurl(HOST+'/m/chat'+zeai.ajxext+'uid='+uid);
        }
		touchDel(dl,dd);
		del.onclick = function(){dl.remove();
			zeai.ajax({url:HOST+'/m/my_msg'+zeai.ajxext+'submitok=ajax_sx_clearmsg',data:{uid:uid}},function(e){var rs=zeai.jsoneval(e);newdian(rs);});
		}
    });
}

function msgtzFn(){
    zeai.listEach(zeai.tag(main,'dt'),function(dt){
		var tid=dt.getAttribute("tid"),t=dt.getAttribute("kind");
        var dd=dt.nextElementSibling;
		var dl=dt.parentNode,del=dl.lastElementChild;
        dd.onclick=function(){
			var b=dt.children[1];
			if(!zeai.empty(b)){
				b.remove();
				if(!zeai.empty(o('num_btm'))){
					var numbtm=parseInt(o('num_btm').innerHTML);
					if(numbtm<=1){
						o('num_btm').remove();
					}else{
						o('num_btm').html(numbtm-1);
					}
				}
			}
			(   (t==1 || t==4) && zeai.openurl(HOST+'/m/my_msg'+zeai.ajxext+'t=tip_detail&tid='+tid)  ) || (t==2 && msg_gift_div(tid)) || (t==3 && msg_hi_div(tid));
        }
		touchDel(dl,dd);
		del.onclick = function(){
			dl.remove();
			zeai.ajax({url:HOST+'/m/my_msg'+zeai.ajxext,data:{submitok:'ajax_tz_del',tid:tid}},function(e){var rs=zeai.jsoneval(e);newdian(rs);});
		}
    });
	function msg_gift_div(tid) {
		var box=o('msg_gift_box');
		zeai.ajax({url:HOST+'/m/my_msg'+zeai.ajxext+'submitok=ajax_gift_div_msg',data:{tid:tid}},function(e){var rs=zeai.jsoneval(e);
			var div=ZeaiM.div2({obj:box,title:'收到【'+rs.nickname+'】礼物',w:30,h:29});
			var em=zeai.tag(box,'em')[0];em=em.children;
			em[0].src       = rs.picurl;
			em[1].html(rs.title);
			em[2].html(rs.price + lovebstr);
			var a=zeai.tag(box,'a'),tipbox;
			a[0].onclick = function (){div.click();zeai.openurl(HOST+'/m/u'+zeai.ajxext+'uid='+rs.uid);}
			a[1].onclick = function (){
				div.click();zeai.openurl(HOST+'/m/gift'+zeai.ajxext+'uid='+rs.uid);
			}
		});	
	}
	function msg_hi_div(tid){
		zeai.ajax({url:HOST+'/m/my_msg'+zeai.ajxext+'submitok=ajax_msg_hi_div',data:{tid:tid}},function(e){var rs=zeai.jsoneval(e);
			if(rs.flag==0){zeai.msg(rs.msg);return;}
			var uid=rs.uid,nickname=rs.nickname,sex=rs.sex,photo_s=rs.photo_s,content=rs.content,ifnew=rs.ifnew,ifhiher=rs.ifhiher,ifchat=rs.ifchat;
			var box_hi,dl,a,dt,dd,img,span,atitle;
			sessionStorage.uid = uid;
			atitle = (ifhiher==0)?'<i class="ico">&#xe6bd;</i> 回复Ta':'<i class="ico">&#xe676;</i> 与Ta聊天';
			if(ifchat==0 && ifhiher==1)atitle='<i class="ico">&#xe62f;</i> 我想认识Ta';
			box_hi = zeai.addtag('div');box_hi.class('box_hi');box_hi.id='box_hi';
			dl = zeai.addtag('dl');
			a  = zeai.addtag('a');a.html(atitle);a.class('zeaibg');
			dt = zeai.addtag('dt');
			dd = zeai.addtag('dd');dd.html(decodeURI(content));
			img = zeai.addtag('img');img.src = photo_s;
			span = zeai.addtag('span');span.html(decodeURI(nickname));
			dt.appendChild(img);dt.appendChild(span);dl.appendChild(dt);dl.appendChild(dd);
			box_hi.appendChild(dl);box_hi.appendChild(a);
			/*处理new和num*/
			if (ifnew == 1){
				
			}
			var div=ZeaiM.div2({removeobj:true,obj:box_hi,title:'收到招呼',w:30,h:29});
			dt.onclick=function(){zeai.openurl(HOST+'/m/u.php?uid='+uid);}
			a.onclick=function(){div.click();
				(ifhiher==0 && zeai.ajax({url:HOST+'/m/u'+zeai.extname,js:1,data:{submitok:'ajax_senddzh',uid:uid}},function(e){var rs=zeai.jsoneval(e);
					if(rs.flag==1){
						tips0_100_msg_hi.html('<i class="ico hi">&#xe6bd;</i>招呼已发送');tips0_100_msg_hi.show();setTimeout(function(){tips0_100_msg_hi.hide()},2100);
					}else if(!zeai.empty(rs.flag)){
						ZeaiM.sorry(rs);
					}else{
						zeai.msg(rs.msg);
					}
				})) || (ifhiher==1 && ifchat==1 && zeai.openurl(HOST+'/m/chat'+zeai.ajxext+'uid='+uid)) || (ifhiher==1 && ifchat==0 && addhn());
			}
		});	
	}
}
function addhn() {
	ZeaiM.div2({obj:kefubox,title:'1对1服务',w:30,h:30});
}
function newdian(rs){
	var numbtm=parseInt(rs.tipnum),
	numtz=parseInt(rs.num_tz),
	numsx=parseInt(rs.num_sx),
	numhi=parseInt(rs.num_hi),
	numsee=parseInt(rs.num_see);
	if(!zeai.empty(o('num_btm'))){
		if(numbtm==0){
			o('num_btm').remove();
		}else{
			o('num_btm').html(numbtm);
		}
	}
	if(!zeai.empty(o('num_tz')) && numtz==0)o('num_tz').remove();
	if(!zeai.empty(o('num_sx')) && numsx==0)o('num_sx').remove();
	if(!zeai.empty(o('num_see')) && numsee==0)o('num_see').remove();
	if(!zeai.empty(o('num_hi')) && numhi==0)o('num_hi').remove();
}

function touchDel(dl,dd){
	var x,xy;
	function mstart(e){x = e.changedTouches[0].clientX;}
	function mmove(e){dlreset();
		var endx = e.changedTouches[0].clientX;
		xy = x - endx;
		if( xy > 30){ZeaiM.fade({arr:[dl],num:'-70px'});
		}else if( xy < -1){ZeaiM.fade({arr:[dl],num:'0'});}
	}
	dd.addEventListener('touchstart',mstart);
	dd.addEventListener('touchmove',mmove);	
	function dlreset(){zeai.listEach(zeai.tag(main,'dl'),function(dl){ZeaiM.fade({arr:[dl],num:'0'});});}
}
window.onload=function(){document.body.onscroll = backtop_alone;}